package com.card;

import cn.hutool.core.util.HexUtil;
import com.alibaba.fastjson.JSONObject;
import com.pojo.UserInfo;
import com.util.DESUtil;
import com.util.IconUtil;
import com.util.ThreeDes;
import lombok.Data;

import javax.imageio.ImageIO;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.*;

@Data
public class CpuCard {
    public static final String DEFAULT_DCCK = "00000000000000000000000000000000" ;
    public static final String DEFAULT_PIN = "123456FFFFFFFFFF" ;
    public static final String CLIENTID = "000000810031" ;
    public static final String DEFAULT_XIAOFEI_KEY = "B6F4468EC6CB4DA8AFB9822CEF3EC6F3" ;

    public static final String DEFAULT_KEY = "6AB6B2FC74094544BE6BC9D8B4CCF63C" ;
//    private static final String CREATE_USER_DIR = "80E0100131380A4081824009A00000000386980701FFFFFFFFFFFFFF01F840FFFF000003" ;
//    private static final String CREATE_NINARY_FILE = "80E000160A2800650040FF00160000" ;

    /**
     * 创建文件夹
     * @param dcck  主控密钥
     * @param dirName  目录名称 两字节十六进制
     * @param dack    文件夹密钥
     * @return
     */
    public static String createDir(String dcck , String dirName , String dack){
        try{
            HexUtil.decodeHex(dirName) ;
        }catch(Exception e) {
            throw new RuntimeException("文件夹名称必须两字节16进制") ;
        }
        if(dirName.length() != 4) {
            throw new RuntimeException("文件夹名称必须两字节16进制") ;
        }
        if(dcck == null) {
            dcck = DEFAULT_DCCK ;
        }
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        byte[] res = ThreeDes.decr(HexUtil.decodeHex(dack) , HexUtil.decodeHex(dcck)) ;
        String miyao = HexUtil.encodeHexStr(res) ;
        String result = "80E0"+dirName+"3138224081824009A00000000386980701FFFFFFFFFFFFFF01F840FFFF000003"+miyao.substring(0 , 32)+"1500" ;
        // 80E010013138224081824009A00000000386980701FFFFFFFFFFFFFF01F840FFFF000003
        // 80E0100131380A4081824009A00000000386980701FFFFFFFFFFFFFF01F840FFFF000003
        return result.toUpperCase() ;
    }

    /**
     * 创建二进制文件
     * @param fileName 文件名
     * @return
     */
    public static String createFile(String fileName){
        try{
            HexUtil.decodeHex(fileName) ;
        }catch(Exception e) {
            throw new RuntimeException("文件名称必须两字节16进制") ;
        }
        if(fileName.length() != 4) {
            throw new RuntimeException("文件名称必须两字节16进制") ;
        }
        String create = "80E0"+fileName+"0A28002E0040FF"+fileName+"0000" ;
        return create ;
    }

    /**
     * 写文件
     * @param fileName 文件名称
     * @param content  文件内容
     * @return
     */
    public static List<String> writeFile(String fileName , String content){
        List<String> result = new ArrayList<String>() ;
        int count = 0 ;
        byte[] arr = HexUtil.decodeHex(fileName) ;
        arr[0] = (byte) ((arr[0] & 0b00011111 | 0b10000000) & 0xff) ;
        arr[0] = (byte) ((arr[0] | 0b10000000) & 0xff) ;
        // 算出真正文件名
        String file = HexUtil.encodeHexStr(arr) ;
        // 构建写文件命令
        int length = content.length() ;
        count = length % 256 == 0 ? length / 256 : length / 256 + 1  ;
        for(int i = 0 ; i < count ; i++) {
            String data = "" ;
            if(i != count - 1) {
                data = content.substring(i*256 , (i+1)*256) ;
            }else{
                data = content.substring(i*256) ;
            }
            String len = getLen(Integer.toHexString(i*128)) ;
            String sl = Integer.toHexString(data.length() / 2) ;
            String len1 = sl.length() == 1 ? "0" + sl : sl ;
            String ml = "00D6" + len + len1 + data ;
            result.add(ml.toUpperCase()) ;
        }

//        String res = "00D6"+file+len+content ;

        return result ;
    }

    private static String getLen(String len){
        if(len.length() == 2) {
            len = "00"+len ;
        }else if(len.length() == 3) {
            len = "0" + len ;
        }else if(len.length() == 1) {
            len = "000" + len ;
        }
        return len ;
    }

    /**
     * 获取外部认证密钥
     * @param random
     * @param dcck
     * @return
     */
    public static String certification(String random , String dcck){
//        System.out.println(random);
        random = random.substring(0 , 8) + "00000000" ;
        if(dcck == null) {
            dcck = DEFAULT_KEY ;
        }
        byte[] res = ThreeDes.encr(HexUtil.decodeHex(random) , HexUtil.decodeHex(dcck)) ;
        return HexUtil.encodeHexStr(res).toUpperCase() ;
    }

    /**
     * 设置目录密钥
     * @param dcck
     * @return
     */
    public static String setDirMiyao(String dack , String dcck){
//        System.out.println(random);
        if(dack == null) {
            dack = DEFAULT_DCCK ;
        }
        if(dcck == null) {
            dcck = DEFAULT_DCCK ;
        }
        byte[] res = DESUtil.desCrypto(HexUtil.decodeHex(dack) , HexUtil.decodeHex(dcck)) ;
        return HexUtil.encodeHexStr(res).substring(0 , 32).toUpperCase() ;
    }

    /**
     * 清空卡结构，并重置主控密钥为dcck
     * @param dcck   主控密钥  不传默认32个0
     * @param ast    复位信息
     * @return
     */
    public static String clearCard(String dcck , String ast){
        if(ast.length() != 32) {
            throw new RuntimeException("ast length err") ;
        }
        if(dcck == null) {
            dcck = DEFAULT_DCCK ;
        }
        String result = null ;
        ast = ast.substring(16 , 32) ;
        byte[] csnl_byte = HexUtil.decodeHex(ast) ;
        byte[] pcsn_byte = HexUtil.decodeHex("FFFFFFFFFFFFFFFF") ;
        for(int i = 0 ; i < csnl_byte.length ; i++) {
            csnl_byte[i] = (byte) ((csnl_byte[i] ^ pcsn_byte[i]) & 0xff) ;
        }
        String CSN = ast + HexUtil.encodeHexStr(csnl_byte).toUpperCase() ;
        byte[] res = ThreeDes.encr(HexUtil.decodeHex(CSN) , HexUtil.decodeHex("46B6A8B059CBB4CBC3EB0DCC4CF72D1C")) ;
//        System.out.println(HexUtil.encodeHexStr(res));
//        String result = HexUtil.encodeHexStr(res) ;
        byte[] arr = ThreeDes.encr(HexUtil.decodeHex(dcck) , res) ;
        // B12B942071E9DE93B12B942071E9DE93
//        System.out.println(HexUtil.encodeHexStr(arr));
        result = HexUtil.encodeHexStr(arr) ;
        return ("80FD00003480FF400E315041592E5359532E4444463031FFFF006040FFFF000003"+result+"0001006000808001").toUpperCase() ;
    }

    /**
     * 根目录密钥维护
     * @param dcck       主控密钥
     * @param dckey      密钥
     * @return
     */
    public static String mainDirMiyao(String dcck , String dckey){
        if(dcck == null) {
            dcck = DEFAULT_DCCK ;
        }
        if(dckey == null) {
            dckey = DEFAULT_KEY ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(dckey) , HexUtil.decodeHex(dcck)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4003613000000"+ edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 32) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }

    /**
     * 数据目录密钥维护
     * @param dack    目录主控密钥
     * @param dckey   目录密钥
     * @return
     */
    public static String dataDirMiyao(String dack , String dckey){
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        if(dckey == null) {
            dckey = DEFAULT_KEY ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(dckey) , HexUtil.decodeHex(dack)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4003613000000" + edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 32) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }

    /**
     * 设置消费密钥
     * @param dack      目录密钥
     * @param dckey     消费密钥
     * @return
     */
    public static String xiaofeiMiyao(String dack , String dckey){
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        if(dckey == null) {
            dckey = DEFAULT_XIAOFEI_KEY ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(dckey) , HexUtil.decodeHex(dack)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4013E13010000" + edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 32) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }


    /**
     * 设置圈存密钥
     * @param dack      目录密钥
     * @param dckey     消费密钥
     * @return
     */
    public static String quancunMiyao(String dack , String dckey){
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        if(dckey == null) {
            dckey = DEFAULT_XIAOFEI_KEY ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(dckey) , HexUtil.decodeHex(dack)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4013F13010000" + edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 32) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }

    /**
     * TAC密钥
     * @param dack      目录密钥
     * @param dckey     tac密钥
     * @return
     */
    public static String tacMiyao(String dack , String dckey){
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        if(dckey == null) {
            dckey = DEFAULT_KEY ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(dckey) , HexUtil.decodeHex(dack)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4003413000000" + edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 32) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }

    /**
     * 设置PIN
     * @param dack
     * @param pin
     * @return
     */
    public static String pinMiyao(String dack , String pin){
        if(dack == null) {
            dack = DEFAULT_KEY ;
        }
        if(pin == null) {
            pin = DEFAULT_PIN ;
        }
        byte[] edckeyArr = ThreeDes.encr(HexUtil.decodeHex(pin) , HexUtil.decodeHex(dack)) ;
        String edckey = HexUtil.encodeHexStr(edckeyArr) ;
        String cmd = "80D4003A0B000003" + edckey ;
        cmd = cmd.substring(0 , 16) +  edckey.substring(0 , 16) ;
        cmd = cmd.toUpperCase() ;
        return cmd ;
    }

    /**
     * 计算mac
     * @param input
     * @param key
     * @return
     */
    private static String callMac(byte[] input , int len , byte[] key , int keyLen , byte[] iniData){
//        int len = input.length ;
//        int keyLen = key.length ;
        int newlen = 0 ;
        byte[] tmpbuf1 = null ;
        byte[] szLeftKey = null ;
        byte[] szRightKey = null ;
        byte[] inbuf = new byte[128] ;
        byte[] tmpbuf = new byte[8] ;

        if(keyLen == 16) {
            szLeftKey = key ;
            szRightKey = Arrays.copyOfRange(key , 8 , 16);
        }else{
            szLeftKey = key ;
            szRightKey = key ;
        }

        System.arraycopy(input , 0 , inbuf , 0 , len);

        if((len%8)!=0)
        {
            inbuf[len]=(byte)(0x80 & 0xff);
            for(int i=1;i< 8-(len%8); i++)
                inbuf[len+i] = (byte)(0x00 & 0xff);
            newlen = len + 8 - len%8;
        }
        else
        {
//            memset(&inbuf[len],0x00, 8);
            inbuf[len] = (byte) (0x80 & 0xff);
            newlen = len + 8;
        }

        if(iniData != null) {
            System.arraycopy(iniData , 0 , tmpbuf , 0 , 8);
        }

        for(int i = 0 ; i < newlen / 8 ; i++) {
            for(int j = 0 ; j < 8 ; j++) {
                tmpbuf[j] = (byte)((tmpbuf[j] ^ inbuf[i*8 +j]) & 0xff) ;
            }
            tmpbuf1 = DESUtil.desCrypto(tmpbuf , szLeftKey) ;
            System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);
        }

        tmpbuf1 = ThreeDes.decr(tmpbuf , szRightKey);
        System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);
        tmpbuf1 = DESUtil.desCrypto(tmpbuf, szLeftKey);
        System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);

        return HexUtil.encodeHexStr(tmpbuf).substring(0 , 16) ;
    }


    /**
     * 消费call_mac
     * @param input
     * @param len
     * @param key
     * @param keyLen
     * @param iniData
     * @return
     */
    private static String callMac1(byte[] input , int len , byte[] key , int keyLen , byte[] iniData){
//        int len = input.length ;
//        int keyLen = key.length ;
        int newlen = 0 ;
        byte[] tmpbuf1 = null ;
        byte[] szLeftKey = null ;
        byte[] szRightKey = null ;
        byte[] inbuf = new byte[128] ;
        byte[] tmpbuf = new byte[8] ;

        if(keyLen == 16) {
            szLeftKey = key ;
            szRightKey = Arrays.copyOfRange(key , 8 , 16);
        }else{
            szLeftKey = key ;
            szRightKey = key ;
        }

        System.arraycopy(input , 0 , inbuf , 0 , len);

        if((len%8)!=0)
        {
            inbuf[len]=(byte)(0x80 & 0xff);
            for(int i=1;i< 8-(len%8); i++)
                inbuf[len+i] = (byte)(0x00 & 0xff);
            newlen = len + 8 - len%8;
        }
        else
        {
//            memset(&inbuf[len],0x00, 8);
            inbuf[len] = (byte) (0x80 & 0xff);
            newlen = len + 8;
        }

        for(int i = 0 ; i < newlen / 8 ; i++) {
            for(int j = 0 ; j < 8 ; j++) {
                tmpbuf[j] = (byte)((tmpbuf[j] ^ inbuf[i*8 +j]) & 0xff) ;
            }
            tmpbuf1 = ThreeDes.encr(tmpbuf , szLeftKey) ;
            System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);
        }

        tmpbuf1 = ThreeDes.decr(tmpbuf , szRightKey);
        System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);
        tmpbuf1 = ThreeDes.encr(tmpbuf, szLeftKey);
        System.arraycopy(tmpbuf1 , 0 , tmpbuf , 0 , 8);

        return HexUtil.encodeHexStr(tmpbuf).substring(0 , 16) ;
    }

    /**
     * 充值
     * @param info      圈存初始化信息
     * @param qcPwd     圈存密钥
     * @return
     */
    public static String chongzhi(String info , String qcPwd , String money){
        if(qcPwd == null) {
            qcPwd = DEFAULT_DCCK ;
        }
        Calendar calendar = Calendar.getInstance() ;
        String clientId = CLIENTID ;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyMMddHHmmss") ;
        String currentTime =  sdf.format(calendar.getTime()) ;
//        currentTime = "20130823185030" ;
        // f59bcceb00008000
        byte[] sessionData = HexUtil.decodeHex(info.substring(16 , 24) + info.substring(8 , 12) + "8000") ;
        byte[] seslk = ThreeDes.encr(sessionData , HexUtil.decodeHex(qcPwd)) ;

        byte[] mac2DataArr = HexUtil.decodeHex(money + "02" + clientId + currentTime) ;
        String mac2 = callMac(mac2DataArr , mac2DataArr.length , seslk , seslk.length , null) ;
        return ("805200000B"+currentTime + mac2.substring(0 , 8)).toUpperCase() ;
    }

    public static String createCardFirst(String ast , String dcck , String random){
        random = random.substring(0 , 8) + "00000000" ;
        if(dcck == null) {
            throw new RuntimeException("主控密钥不能为空") ;
        }
        byte[] csnl = HexUtil.decodeHex(ast.substring(16 , 32)) ;
        byte[] pcsn = HexUtil.decodeHex("FFFFFFFFFFFFFFFF") ;
        byte[] csnr = new byte[8] ;
        for(int i = 0 ; i < 8 ; i++){
            csnr[i] = (byte) ((csnl[i] ^ pcsn[i]) & 0xff) ;
        }
        String csn = HexUtil.encodeHexStr(csnl).substring(0 , 16) + HexUtil.encodeHexStr(csnr).substring(0 , 16) ;
        String tmk = "46B6A8B059CBB4CBC3EB0DCC4CF72D1C" ;
        byte[] dctk = ThreeDes.encr(HexUtil.decodeHex(csn) , HexUtil.decodeHex(tmk)) ;
//        System.out.println(HexUtil.encodeHexStr(dctk)) ;
        String cmd = "84FA01003880FF400E315041592E5359532E4444463031FFFF006040FFFF000003" ;
        byte[] edcck = ThreeDes.encr(HexUtil.decodeHex(dcck) , dctk) ;
        cmd = cmd + HexUtil.encodeHexStr(edcck) ;
        cmd = cmd.substring(0 , 98) + "0001006000808001" ;
//        System.out.println(cmd) ;
        String mac = callMac(HexUtil.decodeHex(cmd) , 57 , dctk , 16 , HexUtil.decodeHex(random)) ;
        return (cmd + mac.substring(0 , 8)).toUpperCase() ;
    }

    /**
     * 消费
     * @param info
     * @param qcPwd
     * @param money
     * @return
     */
    public static String xiaofei(String info , String qcPwd , String money){
        if(qcPwd == null) {
            qcPwd = DEFAULT_XIAOFEI_KEY ;
        }
        Calendar calendar = Calendar.getInstance() ;
//        String clientId = "000000810031" ;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyMMddHHmmss") ;
        String currentTime =  sdf.format(calendar.getTime()) ;
//        currentTime = "20130731185030" ;
        // f59bcceb00008000
        byte[] sessionData = HexUtil.decodeHex(info.substring(22 , 30) + info.substring(8 , 12) + "0006") ;
        byte[] seslk = ThreeDes.encr(sessionData , HexUtil.decodeHex(qcPwd)) ;

        byte[] mac2DataArr = HexUtil.decodeHex(money + "06" + CLIENTID + currentTime) ;
        String mac2 = callMac(mac2DataArr , mac2DataArr.length , seslk , seslk.length , null) ;
        return ("805401000F" + "00000006" +currentTime + mac2.substring(0 , 8)).toUpperCase() ;
    }

    public static void main(String[] args) {

//        System.out.println(chongzhi("00001B000001010075216BD6968037FC9000" , null , "000020"));
//        System.out.println("0082000008"+certification("69AAD05D9000" , "886571d34802407e99a3d8f5daa9ec07"));
//        System.out.println(clearCard(DEFAULT_DCCK , "107833E502446800EF1D7CE912112810"));
        System.out.println(chongzhi("0000000000000100DB8C3797B6FFF54C9000" , "6153f500627a4a7cbe708b52ddd94b7e" , "00000001"));
        System.out.println(xiaofei("00000001000000000001004B876B499000" , null , "00000001"));
//        System.out.println("0082000008"+certification("58B1297E9000" , null));
        // 805200000B2021042316191724D6D728
        // 805200000B2013082318503024D6D728
        // 24D6D728
//        System.out.println("805001020B0100000001"+CLIENTID);
//        System.out.println(xiaofei("0000C35000000000000100DEC194A59000" , null , "00000001"));

    }

//    public static void main(String[] args) {
//        // D68D3E245B234180855230775811F9E4
//        String res = certification("CEE205F19000" , "870ede46d5f1421e9619c36f9eee0a1d") ;
//        System.out.println("0082000008"+res);
//        // 0082000008CACBCCE25E305EB2
//        // 008200000863DC9B5B67238476
//        System.out.println(clearCard(null , "107833E5024468006F117CE912112810"));
//    }

    public static void main1(String[] args) throws Exception {
//        System.out.println(createCardFirst("107833E5024468006F137CE912112810" , "46eea687471b47b8840eec084003e6cc" , "0853E4229000"));
        // 创建mf

        String res = certification("9C83754F9000" , DEFAULT_DCCK) ;
        System.out.println("0082000008"+res);

        res = createDir(DEFAULT_DCCK , "1001" , DEFAULT_DCCK) ;
        System.out.println(res);

        UserInfo staff = new UserInfo() ;
        String douhao = HexUtil.encodeHexStr(",".getBytes()) ;
        String end = HexUtil.encodeHexStr("\n".getBytes()) ;

        String iconPath = "C:\\Users\\lenovo\\Desktop\\icon.png" ;

        String img = IconUtil.icon(ImageIO.read(new FileInputStream(iconPath)) , 0.9f , 1024*5) ;
        String icon = HexUtil.encodeHexStr(img) ;

        String data = icon ;
        staff.setName("杨勇");
        // +douhao +HexUtil.encodeHexStr(staff.getName().getBytes())+ douhao + HexUtil.encodeHexStr(staff.getBh().getBytes())+douhao + HexUtil.encodeHexStr(staff.getQiye().getQyname())+douhao+HexUtil.encodeHexStr((staff.getSex() == 0 ? "女".getBytes() : "男".getBytes()))+douhao+HexUtil.encodeHexStr(sdf.format(staff.getDqtime()).getBytes())+douhao+HexUtil.encodeHexStr(sdf.format(staff.getRztime()).getBytes())+douhao+HexUtil.encodeHexStr(sdf.format(new Date()).getBytes())+end
        if(staff.getName() != null) {
            data = data + douhao + HexUtil.encodeHexStr(staff.getName().getBytes()) ;
        }
        staff.setBh("YY513033111");
        if(staff.getBh() != null) {
            data = data + douhao + HexUtil.encodeHexStr(staff.getBh().getBytes()) ;
        }

//        if(staff.getQiye() != null) {
//            if(staff.getQiye().getQyname() != null) {
        data = data + douhao + HexUtil.encodeHexStr("亚联通信") ;
//            }
//        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;

        staff.setSex(1);
        if(staff.getSex() != null) {
            data = data + douhao + HexUtil.encodeHexStr((staff.getSex() == 0 ? "女".getBytes() : "男".getBytes())) ;
        }

        staff.setDqtime(new Date());
        if(staff.getDqtime() != null) {
            data = data + douhao + HexUtil.encodeHexStr(sdf.format(staff.getDqtime()).getBytes()) ;
        }

        data = data + douhao + HexUtil.encodeHexStr(sdf.format(new Date()).getBytes())+end ;

//        System.out.println(data);
        List<String> result = CpuCard.writeFile("1E" , data) ;
        System.out.println();
//        for (String s: result) {
//            System.out.println(s);
//        }
        System.out.println(JSONObject.toJSON(result));
        System.out.println();


//        System.out.println("805001020B01" + "00036EE8" + CLIENTID);
//        System.out.println(xiaofei("00003B000001000000010030D8FC1F" , DEFAULT_DCCK , "00000500"));
        // 805401000F00000006201307311850307A842423
        // 805401000F0000000620130731185030CDC5B9DD

//        System.out.println("0082000008"+certification("563E9F5E9000" , "5b7dd81fa85d4e44b1ff15c1edfd4a87"));

//        System.out.println(certification("13B839549000" , null));
//        System.out.println(clearCard(DEFAULT_DCCK , "107833E5024468006F147CE912112810"));


        // 32aacc1611ffc2b228b4356105de042b
        // 32AACC1611FFC2B228B4356105DE042B

//        System.out.println(createCardFirst("3B8B8001446800CF1F7CE91211281058" , DEFAULT_DCCK , "3BDFF0C69000"));
        // 84FA01003880FF400E315041592E5359532E4444463031FFFF006040FFFF0000034B78727F93B59D844B78727F93B59D840001006000808001C73580CA
        // 84FA01003880FF400E315041592E5359532E4444463031FFFF006040FFFF0000034B78727F93B59D844B78727F93B59D840001006000808001C73580CA
    }

}
